package UnitTest;

/**
 * @Auther: Administrator
 * @Date: 2019/12/8/008 19 17
 * @Description:
 */
public class ThreadState {
    public static void main(String[] args) {
        new Thread(new TimeWaiting(),"TimeWaiting").start();
        new Thread(new Waiting(),"Waiting").start();
        new Thread(new Blocking(),"BlockingA").start();
        new Thread(new Blocking(),"BlockingB").start();
    }

    static class TimeWaiting implements Runnable {
        @Override
        public void run() {
            while (true) {
                SleepUtils.second(100L);
            }
        }
    }

    static class Waiting implements Runnable{
        @Override
        public void run() {
            while (true) {
                synchronized (Waiting.class){
                    try {
                        Waiting.class.wait();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    static class Blocking implements Runnable{
        @Override
        public void run() {
            synchronized (Blocking.class){
                while (true) {
                    SleepUtils.second(100L);
                }
            }
        }
    }

}
